package com.xuchaotong.service.impl;

import com.xuchaotong.dao.OrderMapper;
import com.xuchaotong.entity.Order;
import com.xuchaotong.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Component
public class OrderServiceImpl implements OrderService{

    @Autowired
    private OrderMapper orderMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void saveOrder(Order order) {
        orderMapper.insert(order);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void saveOrderException(Order order) {
        orderMapper.insert(order);
        throw new RuntimeException();
    }
}
